<?php

namespace App\Admin\Controllers;

use App\Admin\Repositories\VisitorApprovalLog;
use Dcat\Admin\Form;
use Dcat\Admin\Grid;
use Dcat\Admin\Show;
use Dcat\Admin\Http\Controllers\AdminController;

class VisitorApprovalLogController extends AdminController
{
    /**
     * Make a grid builder.
     *
     * @return Grid
     */
    protected function grid()
    {
        return Grid::make(new VisitorApprovalLog(), function (Grid $grid) {
            $grid->model()->orderBy('id', 'desc');
            $grid->column('id')->sortable();
            $grid->column('image_path')->image();
            $grid->column('visitor_name');
            $grid->column('visitor_phone');
            $grid->column('interviewee_name');
            $grid->column('interviewee_phone');
            $grid->column('reason');

            $grid->column('start_time');
            $grid->column('end_time');
            $grid->column('created');
            $grid->column('updated');
            $grid->column('created_at');
            $grid->column('updated_at')->sortable();

            $grid->filter(function (Grid\Filter $filter) {
                $filter->equal('id');

            });
        });
    }

    /**
     * Make a show builder.
     *
     * @param mixed $id
     *
     * @return Show
     */
    protected function detail($id)
    {
        return Show::make($id, new VisitorApprovalLog(), function (Show $show) {
            $show->field('id');
            $show->field('uniqueId');
            $show->field('unionId');
            $show->field('openid');
            $show->field('authorId');
            $show->field('image_path');
            $show->field('visitor_name');
            $show->field('visitor_phone');
            $show->field('interviewee_name');
            $show->field('interviewee_phone');
            $show->field('reason');
            $show->field('author_status');
            $show->field('arrive_status');
            $show->field('passType');
            $show->field('source');
            $show->field('start_time');
            $show->field('end_time');
            $show->field('created');
            $show->field('updated');
            $show->field('created_at');
            $show->field('updated_at');
        });
    }

    /**
     * Make a form builder.
     *
     * @return Form
     */
    protected function form()
    {
        return Form::make(new VisitorApprovalLog(), function (Form $form) {
            $form->display('id');
            $form->text('uniqueId');
            $form->text('unionId');
            $form->text('openid');
            $form->text('authorId');
            $form->image('image_path');
            $form->text('visitor_name');
            $form->text('visitor_phone');
            $form->text('interviewee_name');
            $form->text('interviewee_phone');
            $form->text('reason');
            $form->text('author_status');
            $form->text('arrive_status');
            $form->text('passType');
            $form->text('source');
            $form->text('start_time');
            $form->text('end_time');
            $form->text('created');
            $form->text('updated');

            $form->display('created_at');
            $form->display('updated_at');
        });
    }
}
